﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SpaceGame.Objects;

namespace SpaceGame.Engine
{
    public partial class PlayerSettingsForm : Form
    {
        private Player _player;
        
        public PlayerSettingsForm(Player player)
        {
            _player = player;
            InitializeComponent();
            if (player == null) 
            {
                this.Close();
            }

        }

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {

        }

       

        private void bt_Click(object sender, EventArgs e)
        {
            if (tB.Text != null && tB.Text.Length > 0)
            {
                if (textBox2.Text.Length > 0 && textBox3.Text.Length > 0 && textBox1.Text.Length > 0 && left.Text.Length > 0 && textBox4.Text.Length > 0&&textBox2.Text.Length > 0 && tB.Text.Length < 11 )
                {
                    _player.Fire = textBox4.Text;
                    _player.MoveDown = textBox3.Text;
                    _player.MoveRight = textBox2.Text;
                    _player.MoveUp = textBox1.Text;
                    _player.MoveLeft = left.Text;
               _player.Name = tB.Text;
               this.Close();
                }
            }
            else 
            {
            }

        }

        private void PlayerSettingsForm_Load(object sender, EventArgs e)
        {
            tB.Text = _player.Name;

            pictureBox1.Image = _player.Image;
             textBox4.Text= _player.Fire;
          textBox3.Text  =_player.MoveDown  ;
           textBox2.Text  = _player.MoveRight;
            textBox1.Text= _player.MoveUp ;
             left.Text=_player.MoveLeft ;
        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
           textBox2.Text= e.KeyChar.ToString();
        }

        private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
        {
            textBox3.Text = e.KeyChar.ToString();
        }
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            textBox1.Text = e.KeyChar.ToString();
        }

         private void left_KeyPress(object sender, KeyPressEventArgs e)
        {
            left.Text = e.KeyChar.ToString();
        }

         private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
         {
             textBox4.Text = e.KeyChar.ToString();
         }

         private void pictureBox1_Click(object sender, EventArgs e)
         {

         }

        
    }
}
